/**
 * 
 */
package oop.ex2.filters;

import java.util.ArrayList;

import oop.ex2.filters.exceptions.FilterDataException;

/**
 * Filters file by Bytes content.
 */
public class BinaryFileFilter extends Filter{
	//********************************************************************
	//  Data members :                                                   *
	//********************************************************************
	private byte _byteData;
	//********************************************************************
	//  Methods :                                                        *
	//********************************************************************
	/**
	 * Returns Filter's data as a byte.
	 * @return Filter's data as a byte.
	 */
    public String getData() {
        return _byteData+"";
    }
	/**
	 * Returns a list with all the byte filters.
	 * @return A list with all the byte filters.
	 */
	public ArrayList<Filter> getByteList(){
	    ArrayList<Filter> list = new ArrayList<Filter>();
	    if ( _file.isFile() ) {
	        list.add(this);
	    }
	    return list;
	}   
	/**
	 * Return a clone of the filter.
	 * @return A clone of the filter.
	 */
	public Filter clone(){
		return new BinaryFileFilter();
	}
	/**
	 * Calculates the value of filter's condition.
	 */
	public void calculate(){}//Empty implementation, to maintain
	//efficiency the condition is calculated by search engine.
	/**
	 * Sets the data of the filter.
	 * @param data The data to be set.
	 * @throws FilterDataException In case of wrong filter parameters. 
	 */
	public void setData( String data ) throws FilterDataException{
	    try{ 
	        _byteData = Byte.parseByte(data);
	    }
	    catch ( NumberFormatException e ) {
	        throw new FilterDataException("Error:Invalid filter" +
	        		" parameters");
	    }
	}
}
